package com.cheyun.netsalev3.view

import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.RecyclerView
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.MyAdapter
import com.cheyun.netsalev3.databinding.ActivityCustomerTagBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.utils.InjectorUtils
import com.cheyun.netsalev3.viewmodel.CustomerTagActivityViewModel

class CustomerTagActivity : BaseActivity<ActivityCustomerTagBinding>() {
    override fun initContentView(): Int {
        return R.layout.activity_customer_tag
    }

    private lateinit var adapter: MyAdapter

    override fun initViewModel(): ViewModel? {
        var ids = intent.getStringExtra("ids") ?: ""
        var factory = InjectorUtils.getCustomerTagActivityViewModelFactory(ids)
        return ViewModelProviders.of(this, factory).get(CustomerTagActivityViewModel::class.java)
    }

    override fun initData() {
        binding.viewModel?.listdata?.observe(this, Observer { list ->
            adapter.submitList(list)
        })
    }

    override fun initView() {
        adapter = MyAdapter(R.layout.customer_tag_item, binding.viewModel)
        var recyclerView = binding.root.findViewById<RecyclerView>(R.id.swipe_target)
        recyclerView.adapter = adapter
    }

    override fun onResume() {
        super.onResume()

    }


}
